﻿using System;
using System.ComponentModel;
using System.IO;
using System.Threading;
using System.Windows;
using TagLib;

namespace SilverAmp
{
    public class TrackInfo : ITrackInfo,INotifyPropertyChanged
    {
        private FileInfo _fileinfo;
        public FileInfo Fileinfo
        {
            get { return _fileinfo; }
            set { _fileinfo = value; }
        }

        private string _artist;
        public string Artist
        {
            get { return _artist; }
            set { _artist = value; InvokePropertyChanged("Artist"); }
        }

        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; InvokePropertyChanged("Name"); }
        }

        private string _image;
        public string Image
        {
            get { return _image; }
            set { _image = value; InvokePropertyChanged("Image"); }
        }

        private string _mbid;
        public string mbid
        {
            get { return _mbid; }
            set { _mbid = value; InvokePropertyChanged("mbid"); }
        }

        private Tag _tags;
        public Tag Tags
        {
            get { return _tags; }
            set { _tags = value; InvokePropertyChanged("Tags"); }
        }

        private string _infoUrl;
        public string InfoUrl
        {
            get { return _infoUrl; }
            set { _infoUrl = value; InvokePropertyChanged("InfoUrl"); }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void InvokePropertyChanged(string e)
        {                        
            if (PropertyChanged != null  && !EditMode)
                PropertyChanged(this, new PropertyChangedEventArgs(e));
        }

        private bool EditMode = false;

        public void BeginEdit()
        {
            EditMode = true;
        }

        public void EndEdit()
        {
            EditMode = false;
        }

        public override string ToString()
        {
            return Artist + " - " + Name;
        }
    }
}